<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/statics/js/jquery-3.6.0.js"></script>

    <script>
        $(function (){
            $("#btn").click(function (){
                $.post("${pageContext.request.contextPath}/a2",function (data){
                    var html2="";
                    for (let i = 0; i < data.length; i++) {
                     html2+="<tr>"+
                     "<td>"+data[i].name+"</td>"+
                     "<td>"+data[i].age+"</td>"+
                     "<td>"+data[i].sex+"</td>"+
                     "</tr>"
                    }

                    $("#context").html(html2);
                });
            })
        });
    </script>
</head>
<body>

<input type="button" value="加载数据" id="btn"/>
<table>
    <tr>
        <td>姓名</td>
        <td>年龄</td>
        <td>性别</td>
    </tr>
    <tbody id="context">
    <%--显示数据:从后台接收--%>
    </tbody>
</table>

</body>
</html>
